package br.org.universa.sgos.web;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

@WebFilter(urlPatterns = "/*")
public class FiltroDeCompressao implements Filter {

	private static final Logger logger = Logger.getLogger(FiltroDeCompressao.class);

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {

	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;

        logger.info("Comprimindo dados da requisição da URI " + httpRequest.getRequestURI());

        // TODO - Comprimir

        chain.doFilter(request, response);

	}

	@Override
	public void destroy() {
        BasicConfigurator.configure();
	}

}
